package memberrewards.service;

import hackathon1212.ServletPojoAdapter;

import java.util.HashMap;
import java.util.Map;
import memberrewards.delegate.RewardsDelegate;
import memberrewards.dtos.AccountDetailDTO;

public class AccountBalance extends ServletPojoAdapter {

	private static final long serialVersionUID = -5355970282871440197L;

	protected Object getBusinessMethod(Map<String, String[]> params){

		//Query Params
		final String pan =params.get("pan")!=null? params.get("pan")[0]:null;
		
		//Default response
		final Map<String,String> ret = new HashMap<String, String>();
		ret.put("balance", "0");
		ret.put("status", "Card Not Found");
		final AccountDetailDTO accountDetail = RewardsDelegate.getAccountDetail(pan);
		//Search check card, fetch balance
		if (accountDetail!=null) {
			ret.put("balance",accountDetail.getPointBalance());
			ret.put("status", "Success");
		}
		
		return ret;
	}
}
